package com.xiaoshuidi.cloud.module.member.enums;

import cn.hutool.core.lang.Assert;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum MessageTypeEnum {
    EVALUATED(1, "评价"),
    NOTICE(2, "通知");
    private Integer code;
    private String name;

    public static String getNameByCode(Integer code) {
        MessageTypeEnum messageTypeEnum = Arrays.stream(MessageTypeEnum.values()).filter(p -> p.code.intValue() == code.intValue()).findFirst().orElse(null);
        Assert.isTrue(messageTypeEnum != null, "MessageTypeEnum:{}不存在", code);
        return messageTypeEnum.getName();
    }
}
